1. Field of the Invention
The present invention relates generally to databases and, more particularly, to optimization of database communications.
2. Description of the Background Art
In an object-relational mapping system, it is often desirable to reduce the number of round-trip interactions between an application server and a database server by prefetching query results that may be needed at a later time.
One manner of prefetching is transactional prefetching, which involves fetching a query result at a first time during a transaction and using those results at a later time in the same transaction. Join-based prefetching is one form of transactional prefetching. Two queries can be combined into a single query using a join method. This approach has several disadvantages. If a join is applied to a one-to-many or many-to-one relationship, data from the “many” side of the relationship may be repeated in multiple result rows. Furthermore, current join-based prefetching implementations require the user to choose whether join-based prefetching is enabled at the level of defined relationships. This creates overhead in circumstances where certain information is required in one transaction but not another involving the same tables, as both transactions will request the same data whether or not it is used.
Another manner of prefetching is non-transactional prefetching. Most non-transactional prefetching systems are designed to optimize the traversal of large data sets or subsets thereof while permitting query results to be cached for use across transaction boundaries. A summary of existing non-transactional prefetching systems can be found in “Context-Based Prefetch for Implementing Objects in Relations,” Proceedings of the 25th VLDB Conference Edinburgh, Scotland, 1999 and “Prefetching Based on the Type-Level Access Pattern in Object-Relational DBMSs,” Proceedings of the 17th International Conference on Data Engineering (ICDE '01).
A third manner of prefetching is page-based prefetching, which relies on clustering together in the same database page some parent objects and the child objects to which they have defined relationships. An application server can fetch a page at a time from a page-based prefetching database server, therefore avoiding many round-trips to fetch child objects. This technique does not work well for transactions that do not use child objects, and does not work at all for many-to-one relationships where many parent objects share the same child.
Accordingly, what is desired is an improved approach for transactional data prefetching that is optimized for one-to-one and one-to-many relationships.